package com.kaizige.realtor.Controller;

import com.kaizige.realtor.Dao.houseMsgDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

@Controller
public class imgController {
    @Autowired
    houseMsgDao hmd;
    @RequestMapping("/ownGallery/{id}")
    public String getOwnImg(@PathVariable("id") int id, Model model, HttpSession session){
        model.addAttribute("id",id);
        if(id == 0){
            List<Map<String, Object>> mapList = hmd.queryHmByOwner((String)session.getAttribute("LoginUser"));
            model.addAttribute("houses",mapList);
        }
        return "/img/ownGallery";
    }
    @RequestMapping("/manGallery/{id}")
    public String getManImg(@PathVariable("id") int id, Model model, HttpSession session){
        model.addAttribute("id",id);
        if(id == 0){
            List<Map<String, Object>> maps = hmd.queryAllMsg();
            model.addAttribute("houses",maps);
        }
        return "/img/manGallery";
    }
}
